/*
 * Company  : Datalogic S.p.A.
 * Title    : DEFINITION OF ACQUISITION HANDLERS DATA STRUCTURE
 * Filename : ACQDEF.H
 * System   : Keil-Frankling C-Language Compiler
 * MemoryMod: large
 * Notes    :
 */


#define NMAXCHBARCODE   64   /* code len limit for CODE128 subset C symbology */

#define NMAXCHACQ       NMAXCHBARCODE    /* handlers acquisition lenght limit */
#define DIMACQDATAB     NMAXCHACQ + 1          /* acquisition databuffer size */


#define NMaxChRx        255                       /* both HDLCOM00 & HDLCOM10 */
#define DimRxDataB      NMaxChRx + 1

#define DimTxFrame      3                    /* transmission frame characters */
#define NMaxChTx        255 - DimTxFrame
#define DimTxDataB      NMaxChTx + DimTxFrame + 1

#define DimTxFrame1     1     /* (tx1_hreqst()) transmission frame characters */
#define NMaxChTx1       255 - DimTxFrame1
#define DimTxDataB1     NMaxChTx1 + DimTxFrame1 + 1


#define NMaxChTxIr      65000


#define DIMDATESTR      8
#define DIMTIMESTR      8
#define DIMDATEBUF      DIMDATESTR + 1
#define DIMTIMEBUF      DIMTIMESTR + 1

/* E2PROM buffer parameters */

#define MAXMEMOSTR	126
#define MAXMEMOBUF	MAXMEMOSTR + 1
#define MAXMEMORY	MAXMEMOSTR + 2


/* Repeat Scan parameters  */

#define NSCAN_CMD   100	// In .codesn field is assigned the value NSCAN_CMD + n , with n ranging 
                        // from 2 to NSCAN_EQU ,the decoder handler interprets n as the number
                        // of consecutive repeated readings necessary to validate a code.
#define NSCAN_EQU   5   // maximum input number of consecutive repeated readings of the same code
#define MAX_SCAN    10	// maximum number of repeated code scans without code validation. 
                        // if the code is not validated the decoder handler returns ACQNOV value.

/*
 * HANDLER REQUEST MESSAGE TAGS
 */

struct dec_hreqst_message
{
  unsigned char  acqmode;
  unsigned char  minlen;
  unsigned char  maxlen;
  unsigned char  datatype;
  unsigned char  codesn;
  unsigned char  prompt_x;
  unsigned char  prompt_y;
  unsigned char  *prompt;
  unsigned char  *deflt_str;
};


struct rtx_hreqst_message
{
  unsigned char  len;
  unsigned char  *datap;
  unsigned char  st_addr;
  unsigned char  protc;
};


struct rtx1_hreqst_message
{
  unsigned char  len;
  unsigned char  *datap;
  unsigned char  eot;
  unsigned char  protc;
};

struct kb_hreqst_message
{
  unsigned char  acqmode;
  unsigned char  minlen;
  unsigned char  maxlen;
  unsigned char  datatype;
  unsigned char  section;
  unsigned char  prompt_x;
  unsigned char  prompt_y;
  unsigned char  *prompt;
  unsigned char  *deflt_str;
};

/*
 * HANDLER ANSWER MESSAGE TAGS
 */

struct dec_hanswr_message
{
  unsigned char  stat;
  unsigned char  len;
  unsigned char  errorc;
  unsigned char  datab[ DIMACQDATAB ];
  unsigned char  symblg;
};


struct tx_hanswr_message
{
  unsigned char  stat;
  unsigned char  len;
  unsigned char  errorc;
  unsigned char  datab[ 1 ];
};


struct rx_hanswr_message
{
  unsigned char  stat;
  unsigned char  len;
  unsigned char  errorc;
  unsigned char  datab[ DimRxDataB ];
};

struct kb_hanswr_message
{
  unsigned char  stat;
  unsigned char  len;
  unsigned char  errorc;
  unsigned char  datab[ DIMACQDATAB ];
};

struct time
{
  unsigned char    year;
  unsigned char   month;
  unsigned char     day;
  unsigned char  dayofw;
  unsigned char    hour;
  unsigned char     min;
  unsigned char     sec;
  unsigned char    ampm;
};


struct predef_codes
{
  unsigned char  cod[ NMAXCHACQ + 1 ];
  unsigned char  value;
  void ( *relatefunct )( void );
};


struct ir_hreqst_message
{
  unsigned int   len;
  unsigned char  *datap;
  unsigned char  st_addr;
  unsigned char  protc;
  unsigned int   lenrx;
  unsigned char  *rx_datap;
  unsigned int   timeout;
};


struct ir_hanswr_message
{
  unsigned char  stat;
  unsigned int   len;
  unsigned char  errorc;
  unsigned char  datab[ 1 ];	/* not used */
  unsigned char  event;
  unsigned char  satellite;
};


struct E2prom
{
  unsigned char  len;
  unsigned char  *datap;
};


//Structure for BT Driver
struct BT_CFG{
		unsigned char device_name [31]; // ATS301, max 31 characters 

		//to be decided if this parameter is needed
		unsigned char     device_role; 				//ATS305

		unsigned char	  tpin[5]; 				//ATS318, max 4 alphanumeric characters
		unsigned char     scan_mode; 				//ATS316
		unsigned char     call_mode; 				//ATS330, AT+BBND
		unsigned char     remote_address[13]; 		//
};
struct BT_INFO{
		unsigned char 	  protocol[20]; 			// Firmware version length 30(ATI99) 
		unsigned char     library[20];

		unsigned char	  device_name[31]; 			//ATI
		unsigned char     device_address[13]; 		//ATI4
		unsigned char     remote_address[12]; 		//bt init
};

//Structures and other declarations required for Insertion/Extraction management
typedef enum
{	
	NO_DEVICE=0,						  
	RS232_CABLE=10,
	DCIN_CABLE=11,
	USB_CABLE=12,
	MMCSD_CARD=13		
} DEVICE_TYPE;

typedef enum
{
	NOT_INSERTED=0,
	INSERTED_NOW=1,	
	INSERTED_BEFORE=2,
	EXTRACTED_NOW=3,	
	EXTRACTED_BEFORE=4
} INSERTION_STATE;

typedef struct
{
	INSERTION_STATE	rs232;
	INSERTION_STATE	dcin;
	INSERTION_STATE	usb;
	INSERTION_STATE	mmcsd;
	DEVICE_TYPE dev_type;	
} INSERTION_INFO;

